<template>
  <el-select v-model="value" :placeholder="Data.nickName" >
    <el-option
      v-for="item in TeacherData" 
      :key="item.nickName"
      :label="item.nickName"
      :value="item.nickName"
      @click.native="changeTeacher(item)"
      >
    </el-option>
  </el-select>
</template>

<script>

import { SubjectTeacher } from "@/api/myInfoTeacher/teacherconfig"

export default {
  components: {
  },
  props: {
    Data: {}
  },
  data() {
    return{
      TeacherData: [],
      value: ''
    }
  },
  
  mounted() {
    this.getSubjectTeacher()
  },

  methods: {
    // 教师信息存储到本地
    changeTeacher(item) {
      // console.log(item)
      let person = { subjectName: this.Data.subjectName, userId: item.userId }
      localStorage.setItem(this.Data.subjectName, JSON.stringify(person))
    },
    
    async getSubjectTeacher() {
      // console.log(this.Data.subjectName, 'SubjectTeacher')
      const data = {
        subjectName: this.Data.subjectName
      }
      const res = await SubjectTeacher(data)
      this.TeacherData = res.data
      // console.log(res.data, 'SubjectTeacher')
      // console.log(this.TeacherData, 'TeacherData')
    }
  }
}
</script>

<style>

</style> 